<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
<sx:head />
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<link type="text/css"
	href="css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<link href="css/sytle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	$(function() {
		$("#editAnnouncementList_dialog").dialog({
			autoOpen : false,
			show : "blind",
			hide : "explode"
		});
		getAnnouncementList();
	});
	function getAnnouncementList() {
		var url = "getAnnouncementList";

		$.getJSON(url, null, function callback(data) {
			$.each(data, function(i, n) {
				var row = $("#announcement").clone();
				row.find("#announcement_id").text(n.id);
				row.find("#announcement_group").text(n.group);
				row.find("#announcement_date").text(n.date);
				row.find("#announcement_content").text(n.content);
				row.find("#announcement_user").text(n.user);
				<s:if test="#session.USER_TYPE=='admin'">
				row.find("#announcement_eidt").html(
						"<a href=\"#\" onClick=\"getAnnouncement('"+n.id+"')\">修改</a>");
				</s:if>
				$("#announcementList").append(row);
			});
		});
	}
	function editAnnouncement(type) {
		$("#editAnnouncement_action").val(type);
		$("#editAnnouncementList_dialog").dialog("open");
	}
	function getAnnouncement(the_id) {
		var url = "getAnnouncement";

		$.getJSON(url, {id:the_id}, function callback(data) {
				$("#editAnnouncement_action").val("edit");
				$("#editAnnouncement_date").val(data.date);
				$("#editAnnouncement_content").val(data.content);
				$("#editAnnouncementList_dialog").dialog("open");
		});
	}
</script>
</head>
<body>
	<div class="container">
		<div id="editAnnouncementList_dialog">
			<s:i18n name="globalMessage">
				<s:form id="editAnnouncementForm" action="editAnnouncement">
					<s:hidden id="editAnnouncement_id" name="announcement.id"></s:hidden>
					<s:hidden id="editAnnouncement_action" name="action"></s:hidden>
					<s:if test="#session.USER_GROUP=='admin'">
						<s:select id="editAnnouncement_group" name="announcement.group"
							list="#{'admin':'管理组','children':'儿童班','choir':'唱诗班','liaison':'外联部','biblestudy':'查经班',
							'services':'服务组','user':'用户组'}"
							listKey='key' listValue="value" key="announcement.group"></s:select>
					</s:if>
					<sx:datetimepicker id="editAnnouncement_date"
						name="announcement.date" key="announcement.date"
						displayFormat="yyyy-MM-dd" />
					<s:textarea id="editAnnouncement_content"
						name="announcement.content" key="announcement.content"></s:textarea>
					<s:submit key="announcement.submit"></s:submit>
				</s:form>
			</s:i18n>
		</div>
		<h1>
			<a href="#" onclick="editAnnouncement('add')">添加</a>
		</h1>
		<table id="announcementList" border="1" cellspacing="0"
			style="border-collapse: collapse">
			<tr>
				<th>公告ID</th>
				<th>部门</th>
				<th>时间</th>
				<th>内容</th>
				<th>发布者</th>
				<s:if test="#session.USER_TYPE=='admin'">
					<th>修改</th>
				</s:if>
			</tr>
			<tr id="announcement">
				<td id="announcement_id"></td>
				<td id="announcement_group"></td>
				<td id="announcement_date"></td>
				<td id="announcement_content"></td>
				<td id="announcement_user"></td>
				<s:if test="#session.USER_TYPE=='admin'">
					<td id="announcement_eidt"></td>
				</s:if>
			</tr>
		</table>
	</div>
	</div>
</body>
</html>
